home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Magnum One
/
Magnum One (Mid-American Digital) (Disc Manufacturing).iso
/
d3
/
rettig.arc
/
TRSOURCE.EXE
/
DEPSL.C
< prev
next >
Wrap
C/C++ Source or Header
|
1990-10-22
|
2KB
|
54 lines
/*********
*
* DEPSL.C
*
* by Ralph Davis
* modified by Tom Rettig
*
* Placed in the public domain by Tom Rettig Associates, 10/22/1990.
*
*********/
/* DEPSL: Depreciation by straight-line method
Computes depreciation by subtracting anticipated
resale price of an asset from its original
purchase price and dividing by its anticipated
time of usage.
For example: IBM PC AT purchased at $5000.
Anticipated final sale price $1000.
Anticipated time of service 5 years.
Time currently in service 2 years.
Depreciation = (5000-1000)/5
= $800 / year
* 2 years = $1600
SYNTAX: DEPSL(purchase, resale, total periods, periods to date)
where purchase = initial price
resale = anticipated resale value
total periods = time periods in service life
periods to date = number of periods involved
in calculation
RETURNS: Depreciation
*/
#include "trlib.h"
TRTYPE depsl()
{
if ( PCOUNT==4 && ISNUM(1) && ISNUM(2) && ISNUM(3) && ISNUM(4) )
{
double purchase = _parnd(1);
double resale = _parnd(2);
int totper = (int)_parnd(3);
int periods = (int)_parnd(4);
_retnd( (periods>=totper) ? purchase :
periods * ((purchase - resale) / totper));
}
else
_retnd( (double)ERROR );
}